import 'dart:io';

class SmartHome {
  bool lightsOn = false;
  int thermostatTemp = 20;
  bool securityArmed = false;
  static const int minTemp = 15;
  static const int maxTemp = 30;

  void toggleLights() {
    lightsOn = !lightsOn;
    print("Lights ${lightsOn ? 'ON' : 'OFF'}");
  }

  void setThermostat(int temp) {
    if (temp < minTemp || temp > maxTemp) {
      print("Temperature must be between $minTemp°C and $maxTemp°C");
      return;
    }
    thermostatTemp = temp;
    print("Thermostat set to $temp°C");
  }

  void toggleSecurity() {
    securityArmed = !securityArmed;
    print("Security ${securityArmed ? 'ARMED' : 'DISARMED'}");
  }

  void displayStatus() {
    String dayType = _getDayType();
    print("\nSystem Status:");
    print("- Lights: ${lightsOn ? 'ON' : 'OFF'}");
    print("- Thermostat: $thermostatTemp°C - $dayType");
    print("- Security: ${securityArmed ? 'ARMED' : 'DISARMED'}");
  }

  String _getDayType() {
    if (thermostatTemp % 3 == 0 && thermostatTemp % 5 == 0) {
      return 'Perfect Day';
    } else if (thermostatTemp % 3 == 0) {
      return 'Cool Day';
    } else if (thermostatTemp % 5 == 0) {
      return 'Warm Day';
    } else {
      return 'Normal Day';
    }
  }
}

void main() {
  var smartHome = SmartHome();
  
  while (true) {
    print("\nWhat do you want to do?");
    print("1. Toggle lights");
    print("2. Set thermostat temperature");
    print("3. Toggle security");
    print("4. Display status");
    print("5. Exit");
    
    var choice = stdin.readLineSync();
    switch (choice) {
      case '1':
        smartHome.toggleLights();
        break;
      case '2':
        print("Enter temperature (${SmartHome.minTemp} - ${SmartHome.maxTemp}):");
        var temp = int.tryParse(stdin.readLineSync() ?? '');
        if (temp != null) {
          smartHome.setThermostat(temp);
        }
        break;
      case '3':
        smartHome.toggleSecurity();
        break;
      case '4':
        smartHome.displayStatus();
        break;
      case '5':
        return;
      default:
        print("Invalid choice");
    }
  }
}
